const App = {
  data() {
    return {
      personal_information: [], // 权限人员
      base_system_user_info: {
        User_Number: "",
        Pass_Word: "",
        Name: "",
        Admin_Type: "",
      },
      options: [
        {
          value: "0",
          label: "用户",
        },
        {
          value: "1",
          label: "管理员",
        },
      ],
      Status: [   
        {
          label: "是",
          value: "0",
        },
        {
          label: "否",
          value: "2",
        },
      ],
      Role: [],
      loading: false,
    };
  },
  mounted() {
    let type = sessionStorage.getItem("type");
    console.log(type);
    let User_Number = sessionStorage.getItem("User_Number");
    console.log(User_Number);
    if (type == "Edit") {
      this.Edit(User_Number);
    }
    this.getData();
  },
  methods: {
    getData() {
      const _this = this;
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableName`,
        type: "POST",
        data: {
          Data: "personal_information",
          Condition: "Row_Status = '0'",
        },
        success: function (data) {
          console.log(data);
          _this.personal_information = data;
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },
    Edit(data) {
      const _this = this;
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
        type: "POST",
        data: {
          Data: "base_system_user_info",
          Condition: "Row_Status = '0' And User_Number = '" + data + "'",
        },
        success: function (data) {
          console.log(data);
          _this.base_system_user_info = data[0];
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },
    submitForm(formName) {
      console.log(this.base_system_user_info);
      let lArray = new Array();
      lArray.push(this.base_system_user_info);
      let lJSONObject_base_system_user_info = new Object();
      lJSONObject_base_system_user_info.base_system_user_info = lArray; //换表
      let lJSONObject_DataSet = new Object(); // Modify
      let type = sessionStorage.getItem("type");
      if (type == "Edit") {
        lJSONObject_DataSet.Modify = lJSONObject_base_system_user_info; //换表
      } else {
        lJSONObject_DataSet.Add = lJSONObject_base_system_user_info; //换表
      }
      console.log(lJSONObject_DataSet);
      // return;
      $.ajax({
        headers: requestHeaders(),
        url: `${mh}/clientOperation/generalSaveForClient`,
        type: "POST",
        data: {
          Data: JSON.stringify(lJSONObject_DataSet),
        },
        success: function (data) {
          console.log(data);
          window.history.back();
        },
        complete: (XMLHttpRequest) => {
          requestPretreatment(XMLHttpRequest);
        },
        dataType: "json",
      });
    },
  },
};

const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
app.mount("#app");
